<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
    <style>::-webkit-scrollbar{display: none;}</style>
</head>
<body>
<blockquote class="layui-elem-quote news_search">
    <table id="bg" lay-filter="bg"></table>
</blockquote>

<script id="gjl" type="text/html">

<div class="layui-form-item">
    <form id="cxl" style="float: left" class="layui-form layui-form-item">
        <label class="layui-form-label" style="width: 120px">用户名:</label><input type="text" name="userName" placeholder="请输入用户名"  class="layui-input layui-input-inline">
        <label class="layui-form-label" style="width: 120px">日期:</label><input type="date" name="visitTime" placeholder="请输入用户名"  class="layui-input layui-input-inline">
        <button class="layui-btn layui-btn-primary layui-icon layui-icon-search" lay-submit id="cx" lay-filter="cx"></button>
    </form>
        <button style="margin-left: 1100px;margin-top: -95px " class="layui-btn layui-btn-danger layui-icon layui-icon-delete" lay-event="scs">批量删除</button>
</div>
</script>
    <script id="gj" type="text/html">
        <a class="layui-btn layui-btn-sm layui-btn-danger layui-icon layui-icon-delete" lay-event="sc">
          删除
        </a>
    </script>
<script>
    layui.use(['table','layer','form'],function () {
     var table=layui.table;
        var layer=layui.layer;
        var form=layui.form;
        table.render({
            elem: '#bg',//表格对象
            url:"/lc/lm",//"json/emplayui.json",//实际使用servlet路径(后台服务路径)
            page: true,//分页
            method:'GET',//提交方式
            toolbar: '#gjl',//表格上方普通工具栏
            height:740,
            limit:15,//每页行数

            cols:[[
                {checkbox:true},
                {field:"userName",title:"用户名",sort:true,align:"center"},
                {field:"ipAddress",title:"ip",sort:true,align:"center"},
                {field:"visitTime",title:"访问时间",sort:true,align:"center"},
                {field:"visitURL",title:"访问URL",sort:true,align:"center"},
                {field:"execWay",title:"执行方法",sort:true,align:"center"},
                {field:"execTime",title:"执行时间(毫秒)",align:"center",sort:true},
                {fixed: 'right', title:'操作', toolbar: '#gj'}
            ]]
            ,limits: [5, 10,20,30,50]
        });
        form.on("submit(cx)",function (msg) {
            table.reload("bg",{
                page:{
                    curr:1
                },
                where:{
                    userName:msg.field.userName,
                    visitTime:msg.field.visitTime
                }
            });
            return false;
        });
        table.on("toolbar(bg)",function (msg) {
                var che=table.checkStatus(msg.config.id);
                var ss="";
                for (var i=0;i<che.data.length;i++){
                    ss+=che.data[i].logId+",";
                }
            $.ajax({
                url:"/lc/uss/"+ss,
                method: "put",
                success:function (sj) {
                    if(sj=="cg"){
                        layer.closeAll();
                        table.reload("bg");
                    }else{
                        alert("失败");
                    }
                }

            });

        });
        table.on("tool(bg)",function (msg) {
            var data=msg.data;
            layer.confirm('你确定删除', function(index) {
                $.ajax({
                    url: "/lc/uss/" + data.logId,
                    method: "delete",
                    success: function (sj) {
                        if (sj == "cg") {
                            layer.closeAll();
                            msg.del();
                        } else {
                            alert("失败");
                        }
                    }
                });
            });
        });
    });
</script>
</body>
</html>